<template>
    <div>
        <h3>hook的应用</h3>
        <span>当前求和为：{{sum}}</span>
        <button style="margin-left: 20px" @click="sum++">点我+1</button>

        <div>当前点击时鼠标的坐标为：x：{{point.x}}，y：{{point.y}}</div>
        <div style="color: red">inject:{{car.name}},{{car.price}}</div>
        <hr>
    </div>
</template>

<script>
    import usePoint from '../components/hooks/usePoint'
    import {inject} from 'vue'
    import {ref} from 'vue'
    export default {
        name: "HookApply",
        setup(){
            //数据
            let sum = ref(0)
            // 调usePoint这个函数
            let point = usePoint()
            // console.log(point,point.x,point.y)

            //返回一个对象（常用）

            let car = inject('car')


            return {sum,point,car}
        }
    }
</script>

<style scoped>

</style>